#include <iostream>
#include <string>
using namespace std;
template <class T1,class T2>
class Pair
{
    public:
        T1 key;  //关键字
        T2 value;  //值
        Pair(T1 k,T2 v):key(k),value(v) { };
        bool operator < (const Pair<T1,T2> & p) const;
};
template<class T1,class T2>
bool Pair<T1,T2>::operator < (const Pair<T1,T2> & p) const
//Pair的成员函数 operator <
{ //"小"的意思就是关键字小
    return key < p.key;
}

/* 模板类的定义和使用
 *
*/
template < class T1>
class INT
{
    public:
        T1 value;
        INT(T1 k):value(k) {};// 定义构造函数，初始化k
        void add1()
        {
            // value = value+1000;
            add2();
        }
    private:
        void add2()
        {
            value = value+1000;
        }
};
int main()
{
    Pair<string,int> student("Tom",49); //实例化出一个类 Pair<string,int>
    Pair<string,int> teacher("Tony",34);

    if (student.value < teacher.value)
    {
        std::cout << "Tom's years old is younger!" << std::endl;
    }
    else
    {
        std::cout << "Tony's years old is younger!" << std::endl;
    }
    cout << student.key << " " << student.value << endl;
    INT<int> hu(8);
    hu.add1();
    cout << "test: " << hu.value << endl;
    return 0;
}
